Marie-Hélène Burle
First, we need to answer the question:
Whenever we work on an important document, we know that we should keep key versions
Example:
Home-made versioning looks something like this:
It is quite messy…
from PhD
And inevitably, it leads to this:
from Geek&Poke
Several systems have been developed over the years with various functioning
Then came Git…
Git is an open source distributed vcs created in 2005 by Linus Torvalds for the versioning of the Linux kernel during its development
In distributed vcs, the full history of projects lives on everybody’s machine—as opposed to being only stored on a central server as was the case with centralized vcs. This allows for offline work and multiple backups
Git also introduced an extremely powerful and light-weight branching system
As a result, Git has dominated the competition since 2011
Nowadays, it is indeed extremely rare to come across any other version control system
Git saves the history of a project as a series of snapshots:
The data is stored as blobs, doesn’t create unnecessary copies (unchanged files are referenced from old blobs), and uses excellent compression
These snapshots are identified by commits:
Each commit has a unique hash and contains the following metadata:
As soon as you create the first commit, a pointer called a branch is created and points to that commit
By default, that first branch is called main:
Another pointer (HEAD) points to the branch main
HEAD indicates where we are in the project history
As you create more commits, the history of your project grows and the pointers HEAD and main automatically move to the last commit:
As you create more commits, the history of your project grows and the pointers HEAD and main automatically move to the last commit:
For simplicity, the diagrams can be simplified this way:
One of the many ways this can be useful is that you can revisit old commits by moving HEAD to them:
This will uncompress the corresponding snapshot and you can look at the state of your files at that commit before going back to your branch
Another use is to create multiple branches to explore alternative developments:
You can easily move HEAD between branches
You can even merge branches:
This is a very brief intro: Git is very powerful